import {getFetch,postFetch} from './api'
// const root = "https://test.yueyangshuyuan.com";  //测试环境
// const root = "https://yueyangshuyuan.com";   //生产环境
let root="https://test.yueyangshuyuan.com";
let rootUc="http://test.yueyangshuyuan.com:8081";

let url=window.location.href;
if(url.indexOf("test.yueyangshuyuan.com")!=-1){ //测试
  root="https://test.yueyangshuyuan.com";

}else if(url.indexOf("yueyangshuyuan.com")!=-1){  //生产
  root = "https://yueyangshuyuan.com";
  rootUc="https://uc.yueyangshuyuan.com"

}else {  //本地 用的是测试

  root="https://test.yueyangshuyuan.com";
}
export const fixeParam = () => {
  let dateFormate = Date.parse(new Date());
  return {
    dateFormate:dateFormate
  };
}

export default {
  //GET /sojourn/enums/all
  enumsAll(params){
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/enums/all`,params);
  },
  //POST /sojourn/project/add
  projectAdd(params){
    params = Object.assign(params,fixeParam());
    return postFetch(`${root}/sojourn/project/add`,params)
  },
  projectPage(params){//项目列表
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/project/page`,params)
  },
  //项目详情接口
  // GET /sojourn/project/{projectId}
  projectIdDetail(params,id){//项目列表
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/project/`+id,params)
  },
  alterStatus(params){//修改状态
    return postFetch(`${root}/sojourn/project/alterStatus?projectId=${params.projectId}&operStatus=${params.operStatus}`)
  },
  upToken(params){//七牛文件上传token
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/upToken`,params)
  },
  //编辑项目接口
  // /sojourn/project/edit
  projectEdit(params){
    params = Object.assign(params,fixeParam());
    return postFetch(`${root}/sojourn/project/edit`,params)
  },
  goodsPage(params){//项目列表
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/merch/page`,params)
  },
  merchAlterStatus(params){//商品上架下架
    return postFetch(`${root}/sojourn/merch/alterStatus?merchId=${params.merchId}&shelfStatus=${params.shelfStatus}`)
  },
  delMerch(params){//删除商品
    return postFetch(`${root}/sojourn/merch/delete/${params.merchId}`)
  },
  available(params){//判断商品是否过期
    return getFetch(`${root}/sojourn/merch/available/${params.merchId}`)
  },
  //根据项目的运行状态查项目接口
  // GET /sojourn/project/findByOperStatus
  findByOperStatus(params){
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/project/findByOperStatus`,params)
  },
  //POST /sojourn/merch/add 新建商品
  shopAdd(params){
    params = Object.assign(params,fixeParam());
    return postFetch(`${root}/sojourn/merch/add`,params)
  },
  //GET /sojourn/merch/{merchId} 查询商品详情
  merchDetail(params,merchId){
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/merch/`+merchId,params)
  },
  //POST /sojourn/merch/edit
  shopEdit(params){
    params = Object.assign(params,fixeParam());
    return postFetch(`${root}/sojourn/merch/edit`,params)
  },

  //GET /sojourn/banner/position/available  判断该时间段是否有空余展位
  availableBanner(params){
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/banner/position/available`,params)
  },

  //GET /sojourn/banner/sort/available展位排序值是否重复
  availableSort(params){
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/banner/sort/available`,params)
  },

  //POST /sojourn/banner/add
  bannerAdd(params){
    params = Object.assign(params,fixeParam());
    return postFetch(`${root}/sojourn/banner/add`,params)
  },
  bannerPage(params){
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/banner/page`,params)
  },
  delBanner(params){
    params = Object.assign(params,fixeParam());
    return postFetch(`${root}/sojourn/banner/delete/${params.id}`,params)
  },

  //GET /sojourn/banner/{bannerId}
  bannerDetail(params,bannerId){
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/banner/`+bannerId,params)
  },
  //POST /sojourn/banner/edit
  bannerEdit(params){
    params = Object.assign(params,fixeParam());
    return postFetch(`${root}/sojourn/banner/edit`,params)
  },


  // 获取所有的楼层
  getAllLayout() {
    return getFetch(`${root}/sojourn/layout/all`)
  },
  editLayout(params) {
    return postFetch(`${root}/sojourn/layout/edit`, params)
  },

  //用户管理 用户详情
  // GET /user/customer/detail/{id}
  // GET /sojourn/member/count
  customerDetail(params,id) {
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/member/`+id,params)
  },
  customerList(params) {
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/member/list`,params)
  },
  customerCount(params){
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/member/count`,params)
  },

  //订单列表
  merchOrder(params){
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/order/page`,params)
  },
  //订单管理
  // /sojourn/order/{orderId} 订单详情
  orderDetail(params,orderId){
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/order/`+orderId,params)
  },
  //商户管理--新增商户
  addPerchant(params){
    params = Object.assign(params,fixeParam());
    return postFetch(`${root}/sojourn/merchant`,params)
  },
  //商户管理--校验商户
  validPerchant(params){
    params = Object.assign(params,fixeParam());
    return postFetch(`${root}/sojourn/merchant/valid`,params)
  },
  //商户管理--商户列表
  listPerchant(params){
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/merchant/page`,params)
  },
  //项目分账
  // GET /sojourn/project/{projectId}/share  
  //根据项目id查询项目分账配置
  projectShare(params,projectId){
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/project/`+projectId+`/share`,params)
  },
  // POST /sojourn/project/{projectId}/share  创建分账配置
  projectSharePost(params,projectId){
    params = Object.assign(params,fixeParam());
    return postFetch(`${root}/sojourn/project/`+projectId+`/share`,params)
  },
  // GET /sojourn/project/{projectId}/share/log
  //根据项目id查询项目分账修改记录
  projectShareLog(params,projectId){
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/project/`+projectId+`/share/log`,params)
  },
  //GET /sojourn/merchant/project/{projectId}
  //根据项目查询主商户
  merchantProject(params,projectId){
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/merchant/project/`+projectId,params)
  },
  // GET /sojourn/merchant/simple/page
  //查询所有商户
  simplePage(params){
    params = Object.assign(params,fixeParam());
    return getFetch(`${root}/sojourn/merchant/simple/page`,params)
  },

  //POST /sojourn/order/refund/captcha 退款发送退款验证码
  refundCaptcha(params,orderId){
    params = Object.assign(params,fixeParam());
    return postFetch(`${root}/sojourn/order/refund/captcha?orderId=${params.orderId}`,params)
  },
 
  //POST /sojourn/order/refund 创建退款单
  refundSumit(params){
    params = Object.assign(params,fixeParam());
    return postFetch(`${root}/sojourn/order/refund`,params)
  },
  
  //POST /sojourn/order/{orderId}/clinch/captcha 核销发送验证码
  clinchCaptcha(params,orderId){
    params = Object.assign(params,fixeParam());
    return postFetch(`${root}/sojourn/order/`+orderId+`/clinch/captcha`,params)
  },

  ///sojourn/order/{orderId}/clinch 核销订单
  clinchSumit(params,orderId,captcha){
    params = Object.assign(params,fixeParam());
    return postFetch(`${root}/sojourn/order/`+orderId+`/clinch?captcha=`+captcha,params)
  },
}


